<template>
    <div class="wrapper">
        <div class="card">
            <img class="bg" style="min-height: 160px" src="@/assets/index/bg.png" alt="" />
            <div class="content">
                <div class="top">
                    <span>终端总数</span>
                </div>
                <div class="top center">
                    <span>{{ info.TOTAL_NUM }}</span>
                </div>
                <div class="bottom">
                    <div class="left">
                        <span>电签：</span>
                        <span>{{ info.DQPOS_NUM }}台</span>
                    </div>
                    <div class="right">
                        <span>传统：</span>
                        <span>{{ info.CTPOS_NUM }}台</span>
                    </div>
                </div>
            </div>
        </div>
        <div class="minWrapper">
            <div class="cen">
                <div class="title">
                    <img src="@/assets/ech.png" alt="" />
                    <span>唤醒占比</span>
                </div>
            </div>
            <div id="myChart" :style="{ width: '100%', height: '250px' }"></div>
        </div>
        <div class="minWrapper">
            <div class="cen">
                <!--        <table>-->
                <!--          &lt;!&ndash; 表头行 &ndash;&gt;-->
                <!--          <tr>-->
                <!--            <th align="center">名称</th>-->
                <!--            <th align="center">终端总数</th>-->
                <!--            <th align="center">唤醒总数</th>-->
                <!--            <th align="center">电签</th>-->
                <!--            <th align="center">传统</th>-->
                <!--          </tr>-->
                <!--            &lt;!&ndash; 表格数据行 &ndash;&gt;-->
                <!--          <tr v-for="(item,index) in list">-->
                <!--            <td align="center">{{item.AGENT_NAME}}</td>-->
                <!--            <td align="center">{{item.TOTAL_NUM}}</td>-->
                <!--            <td align="center">{{item.ACT_NUM}}</td>-->
                <!--            <td align="center">{{item.DQPOS_NUM}}</td>-->
                <!--            <td align="center">{{item.CTPOS_NUM}}</td>-->
                <!--          </tr>-->
                <!--        </table>-->
            </div>
        </div>
    </div>
</template>

<script>
import * as echarts from 'echarts'
import { posCountCategory, posPageCountCategory } from '../../api/agent'

export default {
    data() {
        return {
            info: {},
            option: {}
        }
    },
    methods: {
        showorders(chartData) {
            // 基于准备好的dom，初始化echarts实例
            document.getElementById('myChart').setAttribute('_echarts_instance_', '')
            var chartDom = document.getElementById('myChart')
            var myChart = echarts.init(chartDom)
            // 指定图表的配置项和数据
            var option

            option = {
                legend: {
                    top: 'bottom'
                },
                toolbox: {
                    show: true,
                    feature: {}
                },
                color:['#66d6ff','#ffbe6a'],
                series: [
                    {
                        radius: '60%',
                        name: '',
                        type: 'pie',
                        center: ['50%', '40%'],
                        data: chartData,
                    }
                ]
            }
            option && myChart.setOption(option)
        }
    },
    mounted() {
        // posPageCountCategory({ currentPage: this.pageNum }).then(res => {
        //     if (res.code === 200) {
        //         this.list = this.list.concat(res.object.list)
        //         if (!res.object.hasNextPage) {
        //             this.hasData = false
        //         }
        //     }
        // })
        posCountCategory().then(res => {
            this.info = res.object
            const chartData = [
                {
                    name: '电签 ' + res.object.ACT_DQPOS_NUM + ' 台',
                    value: res.object.ACT_DQPOS_NUM
                },
                {
                    name: '传统 ' + res.object.ACT_CTPOS_NUM + ' 台',
                    value: res.object.ACT_CTPOS_NUM
                }
            ]
            this.showorders(chartData)
        })
    }
}
</script>

<style scoped lang="scss">
.wrapper {
    .card {
        position: relative;

        .bg {
            width: 100%;
        }

        .content {
            position: absolute;
            top: 0;
            left: 0;
            height: 100%;
            width: 100%;
            padding: 16px 40px 26px 40px;
            box-sizing: border-box;
            display: flex;
            flex-direction: column;
            justify-content: space-between;

            .top {
                display: flex;
                align-items: center;
                font-size: 0;

                .left {
                    width: 16px;
                }

                span {
                    font-size: 14px;
                    color: #ffffff;
                }

                .right {
                    width: 16px;
                }
            }

            .top.center {
                span {
                    font-size: 40px;
                }
            }

            .bottom {
                display: flex;
                align-items: center;
                justify-content: space-between;
                line-height: 30px;
                color: #ffffff;
                font-size: 14px;
                font-weight: 400;
                color: #ffffff;
                opacity: 1;
            }
        }
    }

    .minWrapper {
        background-color: #ffffff;
        position: relative;
        border-radius: 20px 20px 0 0;
        padding: 0 0 20px 0;

        .cen {
            background: #ffffff;
            opacity: 1;
            padding: 0 10px;

            .title {
                display: flex;
                align-items: center;
                font-size: 0px;
                padding: 10px;

                img {
                    width: 16px;
                }

                span {
                    font-size: 16px;
                    margin-left: 10px;
                }
            }
        }
    }
}
</style>
